package cn.biplam.back.operator.systemManage.sysprivi.role.table;

import java.util.ArrayList;

import cn.biplam.common.client.DataFilter;
import cn.biplam.common.client.OperatorResult;
import cn.biplam.common.interfaces.DataOperator;
import cn.biplam.common.opcode.SysManageCode.RoleOptCode;
import cn.biplam.common.struc.SysStruc.RoleIndexStruc;
import cn.biplam.common.wrapper.ErrorMessage;

/**
 *  角色表操作
 * @author XiaoRuxing Dec 9, 20092:39:40 PM
 * @version 1.0
 */
public class RoleOpt extends DataOperator{

	public RoleOpt() throws ErrorMessage {
		super(RoleIndexStruc.Table_Name);
	}

	@Override
	protected OperatorResult _exchange() throws ErrorMessage {
		ArrayList<String> sql = new ArrayList<String>();
		if(RoleOptCode.Query_By_ID.equals(opId)){
			this.queryById(sql, filter);
			return this.doing(sql,Operator_Type.Select);
		}else{
			throw new ErrorMessage("Operator Exchange outport not found:"+ opId+" !");
		}
	}
	
	/**
	 *  根据角色ID查询角色信息
	 */
	private void queryById(ArrayList<String> sql , DataFilter filter){
		StringBuilder sp = new StringBuilder();
		sp.append(" select * from ");
		sp.append(this.tableName);
		sp.append(" where ");
		sp.append(RoleIndexStruc.Role_ID);
		sp.append("='");
		sp.append(filter.getValue(RoleIndexStruc.Role_ID));
		sp.append("'");
		sql.add(sp.toString());
	}
}
